package me.leon.aop

import android.view.View

/**
 * <p>description：</p>
 * <p>author：Leon</p>
 * <p>date：2019/8/29 0029</p>
 * <p>e-mail：deadogone@gmail.com</p>
 *
 */
object ClickUtils {
    private var mLastClickViewId: Int = 0
    private var mLastClickTime = 0L

    /**
     * 是否是快速点击
     *
     * @param v              点击的控件
     * @param intervalMillis 时间间期（毫秒）
     * @return true:是，false:不是
     */
    fun isFastDoubleClick(v: View, intervalMillis: Long): Boolean {
        val viewId = v.id
        val time = System.currentTimeMillis()
        val timeInterval = Math.abs(time - mLastClickTime)
        if (timeInterval < intervalMillis && viewId == mLastClickViewId) {
            return true
        } else {
            mLastClickTime = time
            mLastClickViewId = viewId
            return false
        }
    }
}